package asruby.lang
{
import asruby.Ruby;
	
public class RubyBoolean extends RubyObject
{
  	public function RubyBoolean( runtime:Ruby,  value:Boolean) {
        super(runtime, (value ? runtime.getTrueClass() : runtime.getFalseClass()), // Don't initialize with class
                false); // Don't put in object space

        if (!value) flags = FALSE_F;
    }

    public static function  createFalseClass(runtime: Ruby): RubyClass {
        var falseClass: RubyClass = runtime.defineClass("FalseClass", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
        runtime.setFalseClass(falseClass);
        falseClass.index = ClassIndex.FALSE;
        
        var fact: CallbackFactory = runtime.callbackFactory(RubyBoolean);
        
        falseClass.defineFastMethod("&", fact.getFastMethod("false_and", RubyKernel.IRUBY_OBJECT));
        falseClass.defineFastMethod("|", fact.getFastMethod("false_or", RubyKernel.IRUBY_OBJECT));
        falseClass.defineFastMethod("^", fact.getFastMethod("false_xor", RubyKernel.IRUBY_OBJECT));
        falseClass.defineFastMethod("to_s", fact.getFastMethod("false_to_s"));
        falseClass.getMetaClass().undefineMethod("new");
        
        falseClass.dispatcher = fact.createDispatcher(falseClass);
        
        return falseClass;
    }
    
    public static function  createTrueClass(runtime: Ruby): RubyClass {
        var trueClass: RubyClass = runtime.defineClass("TrueClass", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
        runtime.setTrueClass(trueClass);
        trueClass.index = ClassIndex.TRUE;
        
        var fact: CallbackFactory = runtime.callbackFactory(RubyBoolean);
        
        trueClass.defineFastMethod("&", fact.getFastMethod("true_and", RubyKernel.IRUBY_OBJECT));
        trueClass.defineFastMethod("|", fact.getFastMethod("true_or", RubyKernel.IRUBY_OBJECT));
        trueClass.defineFastMethod("^", fact.getFastMethod("true_xor", RubyKernel.IRUBY_OBJECT));
        trueClass.defineFastMethod("to_s", fact.getFastMethod("true_to_s"));
        trueClass.getMetaClass().undefineMethod("new");
        
        trueClass.dispatcher = fact.createDispatcher(trueClass);
        
        return trueClass;
    }
	public static function newBoolean(runtime:Ruby,  value:Boolean):RubyBoolean{
		return new newBoolean(runtime,value);
	}
}
}